//
//  MBProgressHUD+MJ.m
//
//  Created by mj on 13-4-18.
//  Copyright (c) 2013年 itcast. All rights reserved.
//

#import "MBProgressHUD+MJ.h"

@implementation MBProgressHUD (MJ)

#pragma mark - 显示一个不会消失的文本信息
+ (MBProgressHUD *)showTingJianTextNeverDismiss:(NSString *)message Frame:(CGRect)frame toView:(UIView *)view
{
    if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
    UIView *hudView;
    if (hudView == nil) hudView = [[UIView alloc] initWithFrame:frame];
    
    [view addSubview:hudView];
    // 快速显示一个提示信息
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:hudView animated:YES];
    hud.labelText = message;
    // 隐藏时候从父控件中移除
    hud.removeFromSuperViewOnHide = YES;
    // YES代表需要蒙版效果
    hud.dimBackground = YES;
    //    hud.userInteractionEnabled = NO;
    return hud;
}

#pragma mark - 快速显示一条文本信息
+(void)showTingJianText:(NSString *)text
{
    // 快速显示一个提示信息
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[[UIApplication sharedApplication].windows lastObject] animated:YES];
    hud.labelText = text;
    // 设置图片
    
    // 再设置模式
    hud.mode = MBProgressHUDModeCustomView;
    
    // 隐藏时候从父控件中移除
    hud.removeFromSuperViewOnHide = YES;
    // 1秒之后再消失
    [hud hide:YES afterDelay:1.0];
}

#pragma mark - 隐藏信息
+ (void)hideHUDForView:(UIView *)view
{
    [self hideHUDForView:view animated:YES];
}


@end
